﻿<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Demo</title>
    <style>
        a.test {
            font-weight: bold;
        }
    </style>
</head>

<body>
    <a href="http://jquery.com/">jQuery</a>
    <a href="http://www.google.com/">google</a>

    <p> Paragraph </p>

    <button class='alert' id="Send">Send</button>

    <script src="./jQuery/jquery.js"></script>
    <script>

        var obj = new Object();
        obj.age = 26;

        var jsonString = JSON.stringify(obj);

        var objFromJson = JSON.parse(jsonString);
        objFromJson.name;

        function coroutine(f)
        {
            var o = f(); // instantiate the coroutine
            o.next(); // execute until the first yield
            return function (x)
            {
                o.next(x);
            }
        }

        // Your code goes here.
        $(document).ready(function ()
        {
            var clock = coroutine(function*(_)
                {
                    while (true)
                    {
                        yield _;
                        console.log('Tick!');
                        yield _;
                        console.log('Tock!');
                    }
                });

                setInterval(clock, 500);

            // Now create a new button element with the alert class. This button
            // was created after the click listeners were applied above, so it
            // will not have the same click behavior as its peers
            //$("<button class='alert'>Alert!</button>").appendTo(document.body);

            // Sets up click behavior on all button elements with the alert class
            // that exist in the DOM when the instruction was executed
            $("button.alert").on("click", function ()
            {
                $.get("http://localhost:8001/getstring", function (string)
                {
                    alert(string)
                })
                console.log("A button with the alert class was clicked!");
            });

        });

    </script>

</body>

</html>
